home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************\
-
- File: V bars scroll thin fade.c
-
- Purpose: Graphic effect to fade main window to solid pattern.
- See comments below for more description.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program in a file named "GNU General Public License".
- If not, write to the Free Software Foundation, 675 Mass Ave,
- Cambridge, MA 02139, USA.
-
- \**********************************************************************/
-
- #include "timing.h"
- #include "V bars scroll thin fade.h"
-
- #define CorrectTime 3
- #define theWindowWidth (boundsRect.right-boundsRect.left)
- #define theWindowHeight (boundsRect.bottom-boundsRect.top)
-
- pascal short VerticalBarsScrollThinFade(Rect boundsRect, Pattern *thePattern)
- {
- RgnHandle topRgn, bottomRgn;
- short offset;
- short iter;
- short barWidth;
- GrafPtr curPort;
- RgnHandle topDestRgn, bottomDestRgn;
- Rect topDestRect, bottomDestRect;
- Rect topSourceRect, bottomSourceRect;
-
- offset=5;
- // barWidth=theWindowWidth/40;
- barWidth=1;
-
- topRgn=NewRgn();
- OpenRgn();
- MoveTo(0, 0);
- iter=0;
- while (iter<theWindowWidth)
- {
- Line(0, theWindowHeight);
- Line(barWidth, 0);
- Line(0, -theWindowHeight);
- Line(-barWidth, 0);
- Move(barWidth*2, 0);
- iter+=barWidth*2;
- }
- CloseRgn(topRgn);
- OffsetRgn(topRgn, boundsRect.left, boundsRect.top);
-
- topDestRgn=NewRgn();
- OpenRgn();
- MoveTo(0, 0);
- iter=0;
- while (iter<theWindowWidth)
- {
- Line(0, offset);
- Line(barWidth, 0);
- Line(0, -offset);
- Line(-barWidth, 0);
- Move(barWidth*2, 0);
- iter+=barWidth*2;
- }
- CloseRgn(topDestRgn);
- OffsetRgn(topDestRgn, boundsRect.left, boundsRect.top);
-
- bottomRgn=NewRgn();
- OpenRgn();
- MoveTo(barWidth, theWindowHeight);
- iter=0;
- while (iter<theWindowWidth)
- {
- Line(0, -theWindowHeight);
- Line(barWidth, 0);
- Line(0, theWindowHeight);
- Line(-barWidth, 0);
- Move(barWidth*2, 0);
- iter+=barWidth*2;
- }
- CloseRgn(bottomRgn);
- OffsetRgn(bottomRgn, boundsRect.left, boundsRect.top);
-
- bottomDestRgn=NewRgn();
- OpenRgn();
- MoveTo(barWidth, theWindowHeight);
- iter=0;
- while (iter<theWindowWidth)
- {
- Line(0, -offset);
- Line(barWidth, 0);
- Line(0, offset);
- Line(-barWidth, 0);
- Move(barWidth*2, 0);
- iter+=barWidth*2;
- }
- CloseRgn(bottomDestRgn);
- OffsetRgn(bottomDestRgn, boundsRect.left, boundsRect.top);
-
- topSourceRect=topDestRect=bottomSourceRect=bottomDestRect=boundsRect;
- topSourceRect.bottom-=offset;
- topDestRect.top+=offset;
- bottomSourceRect.top+=offset;
- bottomDestRect.bottom-=offset;
-
- GetPort(&curPort);
- iter=0;
- while (iter<theWindowHeight)
- {
- StartTiming();
-
- CopyBits(&(curPort->portBits), &(curPort->portBits), &topSourceRect,
- &topDestRect, 0, topRgn);
- CopyBits(&(curPort->portBits), &(curPort->portBits), &bottomSourceRect,
- &bottomDestRect, 0, bottomRgn);
- FillRgn(topDestRgn, *thePattern);
- FillRgn(bottomDestRgn, *thePattern);
-
- iter+=offset;
- TimeCorrection(CorrectTime);
- }
-
- FillRect(&boundsRect, *thePattern);
-
- DisposeRgn(topRgn);
- DisposeRgn(bottomRgn);
- DisposeRgn(topDestRgn);
- DisposeRgn(bottomDestRgn);
-
- return 0;
- }
-